package com.tanhua.model.vo;

import cn.hutool.core.collection.CollUtil;
import com.tanhua.model.mongo.SoulQuestion;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

/**
 * @Desciption:test
 * @Create by:金木yan
 * @Date: 2021/12/10 20:07
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SoulQuestionsVo implements Serializable {
    private String id; //试题id
    private String question; //试题题干
    private List<?> options = Collections.emptyList(); //试题选项列表

    //构建vo
    public static SoulQuestionsVo init(SoulQuestion questions, List list) {
        SoulQuestionsVo vo = new SoulQuestionsVo();
        BeanUtils.copyProperties(questions, vo);
        vo.setId(questions.getId().toHexString());
        if (!CollUtil.isEmpty(list)) {
            vo.setOptions(list);
        }
        return vo;
    }
}
